package com.utilities.parsers;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;

import com.utilities.dataStructures.Range;

public class peaks 
{
	public static void main(String[] args) throws IOException
	{
		String before = "LOCUS       NC_000913            4639675 bp    DNA     circular BCT 30-JUL-2009";
		String after = before.trim().replaceAll(" +", " ");
		System.out.println(after.split(" ")[2]);
//		String inFile1 = "C:/Users/bansalp/data/trx_peaks_a_peaks_out.bed";
//		String inFile2 = "C:/Users/bansalp/data/trx_peaks_b_peaks_out.bed";
//		ArrayList<Range> range1 = read(inFile1);
//		ArrayList<Range> range2 = read(inFile2);
//		HashMap<Range, ArrayList<Range>> map = new HashMap<Range, ArrayList<Range>>();
//		for (Range range : range2)
//		{
//			System.out.println(range.getMetadata());
//			for(Range rg : range1)
//			{
//				if (!range.exclusive(rg))
//				{
//					String chr1 = range.getMetadata().split("\t")[0].trim();
//					String chr2 = rg.getMetadata().split("\t")[0].trim();
//					if (chr1.equalsIgnoreCase(chr2))
//					{
//						ArrayList<Range > temp = null;
//						if (map.containsKey(rg))
//						{
//							temp = map.get(rg);
//						}
//						else
//						{
//							temp = new ArrayList<Range>();
//						}
//						temp.add(range);
//						map.put(rg, temp);
//					}
//				}
//			}
//		}
//		
//		PrintWriter printWriter = new PrintWriter("C:/Users/bansalp/data/out.bed");
//		for(Range range : range1)
//		{
//			if (map.containsKey(range))
//			{
//				printWriter.println(range.getMetadata());
//				ArrayList<Range> temp = map.get(range);
//					for(Range rn : temp)
//					{
//						printWriter.println(rn.getMetadata());
//					}
//					printWriter.println("\n");
//			}
//			
//		}
//		printWriter.flush();
//		printWriter.close();
	}
	
	public static ArrayList<Range> read(String file) throws IOException
	{
		ArrayList<Range> result = new ArrayList<Range>();
		BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
		String readLine = bufferedReader.readLine();
		while(readLine != null)
		{
			String[] param = readLine.split("\t");
			Range range = new Range(Integer.parseInt(param[1]), Integer.parseInt(param[2]), readLine.trim());
			result.add(range);
			readLine = bufferedReader.readLine();
		}
		return result;
	}
}
